package umputun.jutw.utils.logging;

/*
 Copyright 2009 Umputun

 This file is part of JUTW.

 JUTW is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 JUTW is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with JUTW.  If not, see http://www.gnu.org/licenses/.
*/

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;


class ULoggerHandler extends FileHandler {

	public ULoggerHandler(String file) throws SecurityException, IOException {
		super(file, MAX_LOG_SIZE, LOR_ROTATION_COUNT);
	}

	@Override synchronized public void publish(LogRecord record) {
		super.publish(record);
		if (formater == null)
			formater = getFormatter();

		System.out.print(formater.format(record));
	}

	private Formatter formater = null;
	private final static int LOR_ROTATION_COUNT = 5;
	private final static int MAX_LOG_SIZE = 10000000;

}
